package com.gagakuai.bpm.demo;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Component;

import java.util.List;

/*
 * @program: bpm_server
 * @description: 条件事件
 * @author: houhong
 * @create: 2022-07-21 13:26
 */
@Component(value =  "instantiateProcessByConditionDelegate")
public class InstantiateProcessByConditionDelegate  implements JavaDelegate {


    /*
    *
    *  开始事件
    */
    @Override
    public void execute(DelegateExecution execution) throws Exception {

        Integer money = (int)execution.getVariable("money");

        execution.getProcessEngineServices().getRuntimeService();
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();

        List<ProcessInstance> instances = runtimeService
                .createConditionEvaluation()
                .setVariable("money", money)
                .evaluateStartConditions();

    }
}